/**
 * Copyright (C) 2008 Christopher Allen Ogden
 *
 *     This file is part of Odysi.
 *
 *  Odysi is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Odysi is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Odysi.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "object.h"

/**
 * Stores information for mobile objects.
 */
class Mobile:public Object
{
    public:
        /**
         * Constructor.
         */
        Mobile():
            _xOffGoal(0),
            _yOffGoal(0),
            _speed(0),
            _moving(false) {}

        /**
         * Update the object.
         */
        virtual void tick(void);

        /**
         * Move to relative x and y coordinates.
         *
         * @param xOff  The relative X coordinate.
         * @param yOff  The relative Y coordinate.
         * @param zOff  The relative Z coordinate.
         */
        inline virtual void move(float xOff, float yOff, float zOff = 0.0)
        {
            _xOffGoal = xOff;
            _yOffGoal = yOff;
            _zOffGoal = zOff;
            _moving = true;
        }

        /**
         * Speed accessors.
         */
        inline void setSpeed(float speed) { _speed = fabs(speed); }
        inline float getSpeed(void) const { return _speed; }

        /**
         * Find out if the object is moving or not.
         *
         * @return  True if the object is moving, false otherwise.
         */
        inline bool isMoving(void) const { return _moving; }

        /**
         * Set the maximum location.
         *
         * @param maxX  The maximum X location.
         * @param maxY  The maximum Y location.
         */
        inline void setMax(int maxX, int maxY)
        {
            _maxX = maxX;
            _maxY = maxY;
        }

    private:
        float _xOffGoal;    // The relative X offset goal.
        float _yOffGoal;    // The relative Y offset goal.
        float _zOffGoal;    // The relative Z offset goal.
        float _speed;       // The current movement speed.
        bool _moving;       // Whether or not the object is moving.
        int _maxX;          // The maximum X location.
        int _maxY;          // The maximum Y location.
};
